
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:Initialize()

	// This stuff is used by the base weapon ent
	self.Model = "models/props_combine/bunker_gun01.mdl"
	self.Damage = 12
	self.Bulletforce = 14
	self.ReloadTime = 3
	self.Clip = 24
	self.Rof = .6
	self.Cone = .4
	self.NumBullets = 4
	self.MuzzlePos = Vector(0,0,8) //multiply up, right, forward by xyz
	self.Effect = "muzzle_twin"
	self.Tracer = "AR2Tracer"
	self.HitEffect = "hit_bulletsmoke"
	self.Sound = Sound("weapons/sg550/sg550-1.wav")
	self.Pitch = {90,110}
	self.ReloadSound = Sound("weapons/m249/m249_boxout.wav")
	
	util.PrecacheModel(self.Model)
	self:SetModel(self.Model)
	
	self.CurClip = self.Clip //this keeps the weapon from needing a reload when it spawns
	
	//Set ammo values clientside
	self:GetOwner():SetNetworkedFloat("maxvehicleammo",self.Clip)
	self:GetOwner():SetNetworkedFloat("vehicleammo",self.CurClip)
	
end

function ENT:Setup(offset)
	if self:GetOwner() == nil then return end
	self.Offset = offset	
end

function ENT:GetOffset()
return self.Offset end

function ENT:GetWepAngles()
	local ang = self:GetAngles()
	//local ang = self:LocalToWorldAngles(self.Offset)
return ang end

function ENT:GetMuzzlePos()
	local vec = self:GetPos()
	vec = vec + self:GetTrueForward() * 8
return vec end

function ENT:GetTrueUp()
	return self:GetUp()
end

function ENT:GetTrueForward()
	return self:GetForward()
end

function ENT:GetTrueRight()
	return self:GetRight()
end

function ENT:Think()
	if self:GetOwner() != NULL and self:GetOwner() != nil then
		if self:GetOwner():KeyDown(IN_ATTACK) then
			if self:IsReloading() then return end
			if self:CanFire() then
				self:FireBullet( self.Damage, self.BulletForce, self.NumBullets, self.Cone, self.Effect, self.Sound, self.Pitch, self.Tracer, self.HitEffect )
			end
		end
	end
end